import sys

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
import time

from selenium.webdriver.common.keys import Keys


wd = webdriver.Chrome()
wd.get("http://172.16.60.11/")
wd.implicitly_wait(10)
wd.maximize_window()
wd.find_element_by_xpath("//../span[text() = '用户中心登录']").click()

# 输入邮箱
wd.find_element_by_xpath("//input[@placeholder= '邮箱']").send_keys("admin@forensix.cn")

# 输入密码
wd.find_element_by_xpath("//input[@placeholder = '密码']").send_keys("123456")

# 点击“授权并登录”按钮
wd.find_element_by_xpath("//span[text() = '授权并登录']").click()
wd.find_element(By.XPATH,'//span[text()="案件管理"]').click()
wd.find_element(By.XPATH,'//span[text()="委托评审"]').click()
try:
    # 搜索创建的案件
    ele = wd.find_element(By.XPATH, '//input[@placeholder="姓名/编号/名称/委托单位/标签"]')
    csname = "侯旭非法吸收公众存款案"
    ele.send_keys(csname)
    ele.send_keys(Keys.ENTER)
    # 点击进入查看案件详情
    wd.find_element(By.XPATH,'//a[@title="'+csname+'"]').click()

    # 跳转到检材tab页面
    wd.find_element(By.XPATH,'//div[text()="检材"]').click()
    wd.find_element(By.XPATH,'//div[@class="f-fl evidence js-lightgallery"]//span[text()="入库"]').click()

    # 点击“入库”按钮
    wd.find_element(By.XPATH,'//div[@class="f-tar"]//span[text()="入库"]').click()

    # 点击“提检”按钮
    wd.find_element(By.XPATH,'//div[@class="el-card__body"]//span[text()="提检"]').click()
    wd.find_element(By.XPATH,'//span[text()="确定"]').click()
except Exception:
    print(sys.exc_info()[0], sys.exc_info()[1])
finally:
    time.sleep(10)
    wd.quit()
